import Group from "../entities/Group";
import Operator from "./Operator";
import { RC } from "../config/RC";

class EnterGroupOperator extends Operator {
    public async execute(): Promise<RC> {
        try {
            const userId = this.args.getProperty("userId");
            const groupId = this.args.getProperty("groupId");
            await Group.AddNewMember(groupId, userId);
            return RC.SUCCESS;
        } catch (error) {
            // 处理异常情况
            console.error('Error entering group:', error);
            return RC.INTERNAL_ERROR;
        }
    }
}

export default EnterGroupOperator;